﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Simulation.LogicalGate
{
    /// <summary>
    /// This class represents a two input channel gate control.
    /// </summary>
    [Serializable]
    public abstract class TwoInputGate
    {
        /// <summary>
        /// This field holds the first source bytes for the logical gate operation (Input A).
        /// </summary>
        private Byte a;

        /// <summary>
        /// This field holds the second source bytes for the logical gate operation (Input B).
        /// </summary>
        private Byte b;

        /// <summary>
        /// Initializes a new instance of the <see cref="TwoInputGate"/> class.
        /// </summary>
        protected TwoInputGate()
        {
            this.a = new Byte();
            this.b = new Byte();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TwoInputGate"/> class.
        /// </summary>
        /// <param name="a">The first source bytes for the logical gate operation (Input A).</param>
        /// <param name="b">The second source bytes for the logical gate operation (Input B).</param>
        protected TwoInputGate(Byte a, Byte b)
        {
            this.a = a;
            this.b = b;
        }

        /// <summary>
        /// Gets or sets the first source bytes for the logical gate operation (Input A).
        /// </summary>
        /// <value>The first source bytes for the logical gate operation (Input A).</value>
        public Byte A
        {
            get { return a; }
            set { a = value; }
        }

        /// <summary>
        /// Gets or sets the second source bytes for the logical gate operation (Input B).
        /// </summary>
        /// <value>The second source bytes for the logical gate operation (Input B).</value>
        public Byte B
        {
            get { return b; }
            set { b = value; }
        }

        /// <summary>
        /// Gets the logical result, which is defined by the gate and the specified input values.
        /// </summary>
        /// <returns>The result of the logical gate.</returns>
        public abstract Byte GetResult();
    }
}